package com.sesample.seandroidsample;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

public class CartActivity extends SingleFragmentActivity {

  @Override
  protected Fragment createFragment() {
    return new CartFragment();
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);
    return super.onCreateOptionsMenu(menu);
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    Intent i = null;
    // Handle presses on the action bar items
    switch (item.getItemId()) {
    case R.id.menu_item_view_products:
      i = new Intent(this, ProductListActivity.class);
      startActivity(i);
      return true;
    case R.id.menu_item_view_cart:
      i = new Intent(this, CartActivity.class);
      startActivity(i);
      return true;
    default:
      return super.onOptionsItemSelected(item);
    }
  }
}
